package com.code.nowcoder;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/28 17:56
 */
public class The87 {
    /**
     * @param n     int整型
     * @param seed1 long长整型
     * @param seed2 long长整型
     * @param seed3 long长整型
     * @return long长整型
     */
    public long work(int n, long seed1, long seed2, long seed3) {
        // write code here

        long result = 0;
        for (int i = 1; i < n; i++) {
            long seed4 = ((seed1 + seed2) % 998244353) * seed3 % 998244353;
            result += seed2 * seed3 % 12131415;
            seed3 = seed2;
            seed2 = seed1;
            seed1 = seed4;
        }
        return result;
    }
}
